﻿using System.Collections.Generic;
using Minesweeper.Logic;

namespace Minesweeper.Test
{
    public class Solver
    {
        public static int[,] Solve(List<Position> Bombs, int DimensionX, int DimensionY)
        {
            var SolvedPlan = new int[DimensionX,DimensionY];
            
            foreach (Position BombPosition in Bombs)
            {
                var PosX = BombPosition.XCoordinate - 1;
                while (PosX <= BombPosition.XCoordinate + 1)
                {
                    var PosY = BombPosition.YCoordinate - 1;
                    while (PosY <= BombPosition.YCoordinate + 1)
                    {
                        if (PosY != BombPosition.YCoordinate || PosX != BombPosition.XCoordinate)
                        {
                            if (PosY >= 0 && PosY <= SolvedPlan.GetUpperBound(1) && PosX >= 0 && PosX <= SolvedPlan.GetUpperBound(0))
                            {
                                SolvedPlan[PosX, PosY]++;
                            }
                        }
                        PosY++;    
                    }
                    PosX++;
                }
                    
            }
            return SolvedPlan;
        }
    }
}